#pragma once
#include <vector>
namespace xpam
{
    namespace math
    {
        template<class T>
        class matrix
        {
            std::vector<T> _data;
            unsigned int _width;
            unsigned int _height;
        public:
            matrix()
            {
                resize(0, 0);
            }
            matrix(unsigned int width, unsigned int height)
            {
                resize(width, height);
            }

            void from_array(T * data)
            {
                int n = _width * _height;
                for (int i=0; i < n; i++)
                {
                    _data[i] = data[i];
                }
            }

            void to_array(T * data)
            {
                int n = _width * _height;
                for (int i=0; i < n; i++)
                {
                    data[i] = _data[i];
                }
            }

            void resize(unsigned int width, unsigned int height)
            {
                _data.resize(width * height);
                _width = width;
                _height = height;
            }
            unsigned int width()
            {
                return _width;
            }
            unsigned int height()
            {
                return _height;
            }
            T & at(unsigned int x, unsigned int y)
            {
                return _data[x + y * _width];
            }

        };
    }
}